{
 "metadata": {
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.1"
  },
  "orig_nbformat": 4,
  "kernelspec": {
   "name": "python3",
   "display_name": "Python 3.9.1 64-bit"
  },
  "interpreter": {
   "hash": "ae7dbc91df3af0185ffb34e3fe12035cb4fadd9b684f5beca1182a2e24aafe6e"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2,
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "source": [
    "import csv\r\n",
    "readDatas = {}\r\n",
    "mmap={'M':False,'F':True}\r\n",
    "with open('data.csv', 'rt') as f:\r\n",
    "    cr = csv.reader(f)\r\n",
    "    for row in cr:\r\n",
    "        if not(int(row[0]) in readDatas):\r\n",
    "            readDatas[int(row[0])]=[]\r\n",
    "        readDatas[int(row[0])].append(mmap[row[1]])\r\n",
    "m3=m2f1=m1f2=f3=0\r\n",
    "for i in readDatas.values():\r\n",
    "    fc=mc=0\r\n",
    "    for j in i:\r\n",
    "        if j:\r\n",
    "            fc+=1\r\n",
    "        else:\r\n",
    "            mc+=1\r\n",
    "    if mc==3:\r\n",
    "        m3+=1\r\n",
    "    elif mc==2 and fc==1:\r\n",
    "        m2f1+=1\r\n",
    "    elif mc==1 and fc==2:\r\n",
    "        m1f2+=1\r\n",
    "    elif fc==3:\r\n",
    "        f3+=1\r\n",
    "print('3男\\t=',m3)\r\n",
    "print('2男1女\\t=',m2f1)\r\n",
    "print('1男2女\\t=',m1f2)\r\n",
    "print('3女\\t=',f3)"
   ],
   "outputs": [
    {
     "output_type": "stream",
     "name": "stdout",
     "text": [
      "3男\t= 39\n",
      "2男1女\t= 81\n",
      "1男2女\t= 54\n",
      "3女\t= 12\n"
     ]
    }
   ],
   "metadata": {}
  }
 ]
}